import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TIntegralShopItemNew } from "../../../Message/Db/Tables/TIntegralShopItemNew";
import { Cache } from "../cache/Cache";
type int = number;
//class IntegralShopItemNewConfig
    
    export  class IntegralShopItemNewConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._infoArr = new Array<any>();
            if (IntegralShopItemNewConfig._instance != null) 
            {
                throw new Error("IntegralShopItemNewConfig 单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_integral_shop_item_new.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TIntegralShopItemNew();
                loc1.career = loc2.career;
                loc1.id = loc2.id;
                loc1.itemCode = loc2.itemCode;
                loc1.needBroadcast = loc2.needBroadcast;
                loc1.needLevel = loc2.needLevel;
                loc1.needRecord = loc2.needRecord;
                loc1.price = loc2.price;
                loc1.priceOrigin = loc2.priceOrigin;
                loc1.shopId = loc2.shopId;
                loc1.kind = loc2.kind;
                loc1.isActive = loc2.isActive;
                this._map[loc1.shopId + "_" + loc1.id] = loc1;
                this._infoArr.push(loc1);
            }
            return;
        }

        public getItemsByShopId(arg1: int, arg2: int): Array<any>
        {
            var loc3=null;
            var loc1=[];
            var loc2=Cache.instance.role.entityInfo.career;
            var loc4=0;
            var loc5=this._infoArr;
            for(loc3 of loc5) 
            {
                if (!(loc3.shopId == arg1 && loc2 & loc3.career && loc3.isActive == arg2)) 
                {
                    continue;
                }
                loc1.push(loc3);
            }
            return loc1;
        }

        public getPreviewItemByShopId(arg1: int, arg2: int): Map<any, any> /* flash.utils.Dictionary */
        {
            var loc3=null;
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            var loc2=this.getItemsByShopId(arg1, arg2);
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                if ((loc3 = loc2[loc4] as TIntegralShopItemNew).kind <= 4 || loc3.kind == 11 || loc3.kind == 12) 
                {
                    loc1[loc3.kind] = loc3;
                }
                ++loc4;
            }
            return loc1;
        }

        public static get instance(): IntegralShopItemNewConfig
        {
            if (IntegralShopItemNewConfig._instance == null) 
            {
                IntegralShopItemNewConfig._instance = new IntegralShopItemNewConfig();
            }
            return IntegralShopItemNewConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_infoArr: Array<any>;

        /* internal */ static /* var */_instance: IntegralShopItemNewConfig;
    }
